package flc.ast.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.youth.banner.adapter.BannerAdapter;
import com.youth.banner.util.BannerUtils;

import java.util.List;

import flc.ast.R;
import stark.common.bean.StkResBean;

public class MyBannerAdapter extends BannerAdapter<StkResBean, MyBannerAdapter.ImageTitleHolder> {

    private Context context;

    public MyBannerAdapter(List<StkResBean> datas, Context context) {
        super(datas);
        this.context=context;
    }

    private int selPosition=0;

    public void setSelPosition(int selPosition) {
        this.selPosition = selPosition;
    }

    @Override
    public ImageTitleHolder onCreateHolder(ViewGroup parent, int viewType) {
        return new ImageTitleHolder(BannerUtils.getView(parent, R.layout.item_banner));
    }

    @Override
    public void onBindView(ImageTitleHolder holder, StkResBean data, int position, int size) {
        Glide.with(context).load(data.getThumbUrl()).into(holder.imageView);
        holder.textView.setText(data.getName());
    }

    public class ImageTitleHolder extends RecyclerView.ViewHolder {
        public ImageView imageView;
        public TextView textView;

        public ImageTitleHolder(@NonNull View view) {
            super(view);
            imageView = view.findViewById(R.id.ivBannerItemImg);
            textView = view.findViewById(R.id.tvBannerItemTitle);
        }
    }
}
